package edu.luc.cs.backend;
/**
 * PersonName Class
 * Represents a person's given and family name
 * @author Christopher Bun
 *
 */


public class PersonName {
	private String familyName;
	private String givenName;
	
	public PersonName(String familyName, String givenName) {
		setFamilyName(familyName);
		setGivenName(givenName);
	}
	
	//-------------ACCESSORS------------------//
	public void setFamilyName(String familyName) {
		this.familyName = familyName;
	}
	
	public String getFamilyName() {
		return familyName;
	}
	
	public void setGivenName(String givenName) {
		this.givenName = givenName;
	}
	
	public String getGivenName() {
		return givenName;
	}
	
	public String getEnglishName() {
		return givenName + " " + familyName;
	}
	
	
	//--------------COMPARISON------------------//
	public boolean equals(PersonName p) {
		return this.familyName.compareTo(p.familyName) == 0 &&
			   this.givenName.compareTo(p.givenName) == 0;
	}
	
	public boolean lessThan(PersonName p) {
		if (this.familyName.toLowerCase().
				compareTo(p.familyName.toLowerCase()) == 0)
					return this.givenName.toLowerCase().
						compareTo(p.givenName.toLowerCase()) < 0;
		else
			return this.familyName.toLowerCase().
				compareTo(p.familyName.toLowerCase()) < 0;
	}
	
	
	public String toString() {
		return getEnglishName();
	}
}
